# Maintainer: Patrick Stewart <patstew@gmail.com>

pkgbase=mingw-w64-python-jsonschema
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-jsonschema" "${MINGW_PACKAGE_PREFIX}-python3-jsonschema")
pkgver=2.5.1
pkgrel=1
pkgdesc="An implementation of JSON Schema validation for Python (mingw-w64)"
arch=('any')
url="http://pypi.python.org/pypi/jsonschema"
license=('MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-python2-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python3-setuptools")

source=("http://pypi.python.org/packages/source/j/jsonschema/jsonschema-$pkgver.tar.gz")
md5sums=('374e848fdb69a3ce8b7e778b47c30640')

all_build() {
  cd "${srcdir}/jsonschema-${pkgver}"
	
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/${1} setup.py install \
    --prefix=${MINGW_PREFIX} --root=${pkgdir} --optimize=1

  find "${pkgdir}/" -name "*.pyc" -delete
  find "${pkgdir}/" -type d -empty -delete
}

package_python3-jsonschema() {
  local interpreter=python3
  depends=("${MINGW_PACKAGE_PREFIX}-python3")
	

  all_build ${interpreter}
	
  install -D -m644 json/LICENSE $pkgdir/usr/share/licenses/$pkgname/LICENSE
}

package_python2-jsonschema() {
  local interpreter=python2
  depends=("${MINGW_PACKAGE_PREFIX}-python2")
	
  all_build ${interpreter}
	
  install -D -m644 json/LICENSE $pkgdir/usr/share/licenses/${pkgname}2/LICENSE
	
	cd "${pkgdir}${MINGW_PREFIX}"/bin
  for _f in *; do
    mv ${_f} ${_f/%.*/}2${_f/${_f/%.*/}/}
  done
}

package_mingw-w64-i686-python2-jsonschema() {
  package_python2-jsonschema
}

package_mingw-w64-i686-python3-jsonschema() {
  package_python3-jsonschema
}

package_mingw-w64-x86_64-python2-jsonschema() {
  package_python2-jsonschema
}

package_mingw-w64-x86_64-python3-jsonschema() {
  package_python3-jsonschema
}
